/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataAccess;

import Entities.EnrollEventEntities;
import Entities.RegisterEntities;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author ducdm_b00875
 */
public class EnrollEventDataAccess {
    
    ConnectDatabase objCD = new ConnectDatabase();
    RegisterEntities registerEntities;
    List<RegisterEntities> registerList;

    public EnrollEventDataAccess() {
        registerList = new ArrayList<RegisterEntities>();
    }
    
    public List<RegisterEntities> getByEventId(String eventId) throws Exception, ClassNotFoundException{
        registerList.clear();
        objCD.open();
        objCD.setMode(ConnectDatabase.CALLABLE);
        objCD.setStatement("{call sp_EnrollEvent_ViewByEventId(?)}");
        objCD.castm.setString(1, eventId);
        objCD.doQuery();
        if (objCD.rs != null) {
            while (objCD.rs.next()) {                
                registerEntities = new RegisterEntities(objCD.rs.getInt("RegisterId"), objCD.rs.getString("RegisterName"), objCD.rs.getString("Email"), objCD.rs.getString("UserName"), objCD.rs.getString("Password"), objCD.rs.getFloat("MoneyNumber"), objCD.rs.getString("Phone"), objCD.rs.getString("Gender"), objCD.rs.getString("Images"), objCD.rs.getString("Address"), objCD.rs.getDate("DateCreate"));
                registerList.add(registerEntities);
            }
        }
        objCD.close();
        
        return registerList;
    }
    
    public RegisterEntities getRegisterEntities() {
        return registerEntities;
    }

    public void setRegisterEntities(RegisterEntities registerEntities) {
        this.registerEntities = registerEntities;
    }

    public List<RegisterEntities> getRegisterList() {
        return registerList;
    }

    public void setRegisterList(List<RegisterEntities> registerList) {
        this.registerList = registerList;
    }
   
}
